# -*- coding: utf-8 -*-

import numpy as np
import pandas as pd

def averageBlending(a,b):
    sub1=pd.read_csv('result/submission.csv')
    sub2=pd.read_csv('result/submission2.csv')
    
    p1=sub1.prob.values
    p2=sub2.prob.values
    
    p1=p1*a
    p2=p2*b
    
    p=p1+p2
    
    instanceID=sub1.instanceID.values
    
    output=pd.DataFrame({'instanceID':instanceID,'prob':p})
    output.to_csv('result/submission3.csv',index=False) 
    
def toExpected():
    df_sub=pd.read_csv('result/submission3.csv')
    mean=np.mean(df_sub.prob.values)    
    p=0.0273/mean
    df_sub['prob']=df_sub.prob.apply(lambda x:x*p)
    df_sub.to_csv('result/submission4.csv',index=False)    
if __name__=='__main__':
   averageBlending(0.5,0.5)
   toExpected()
